﻿/*
 * KLF Headless Browser
 * Written by Kris Oye <kristianoye@gmail.com>
 * Copyright (C) 2011-2012.  All rights reserved.
 */
namespace KLF.Lib.Browser.XMLHTTP
{
    #region Using Statements

    using KLF.Lib.Browser.DOM;
    using KLF.Lib.Browser.DOM.TypedArray;

    #endregion

    public enum XMLHttpRequestState
    {
        UNSENT = 0,
        OPENED = 1,
        HEADERS_RECEIVED = 2,
        LOADING = 3,
        DONE = 4
    }

    /// <summary>
    /// Based on W3C Working Draft 17 January 2012
    /// </summary>
    public interface IXMLHttpRequest : IXMLHttpRequestEventTarget
    {
        #region XMLHttpRequest Compliance

        // Attributes
        object onreadystatechange { get; }
        int readyState { get; }
        int timeout { get; set; }
        IXMLHttpRequestUpload upload { get; }
        bool withCredentials { get; set; }

        // Request methods
        void open(string method, string url, bool async, string user, string password);
        void open(string method, string url, bool async, string user);
        void open(string method, string url, bool async);
        void open(string method, string url);
        void setRequestHeader(string header, string value);
        void send();
        void send(IArrayBuffer data);
        void send(IBlob data);
        void send(Document data);
        void send(string data);
        void send(FormData data);
        void abort();

        int status { get; }
        string statusText { get; }

        string getResponseHeader(string header);
        string getAllResponseHeaders();
        void overrideMimeType(string mime);
        IXMLHttpRequestResponseType responseType { get; set; }
        object response { get; }
        string responseText { get; }
        Document responseXML { get; }

        #endregion
    }
}
